package backend.majiong.yaku.yaku;

import backend.MainGame;
import backend.majiong.Pai;
import backend.majiong.Player;
import backend.majiong.yaku.AbstractYaku;
import backend.majiong.yaku.HandCombo;

public class Cyanta extends AbstractYaku {

    @Override
    public boolean checkYaku(Player player, HandCombo combo, MainGame mainGame) {
        if(new JunCyan().checkYaku(player, combo, mainGame)) {
            return false;
        }
        // 所有的面子带幺九牌
        // 顺子
        for (Pai pai : combo.getSunZi()) {
            if(pai.getNum() != 1 && pai.getNum() != 7) {
                return false;
            }
        }
        // 刻子
        for (Pai pai : combo.getKeZi()) {
            if(pai.getNum() != 1 && pai.getNum() != 9 && pai.getType() != Pai.TYPE_ZI) {
                return false;
            }
        }
        // 杠子
        for (Pai pai : combo.getGangZi()) {
            if(pai.getNum() != 1 && pai.getNum() != 9 && pai.getType() != Pai.TYPE_ZI) {
                return false;
            }
        }
        // 雀头
        Pai pai = combo.getDuiZi();
        if(pai.getNum() != 1 && pai.getNum() != 9 && pai.getType() != Pai.TYPE_ZI) {
            return false;
        }
        return true;
    }

    @Override
    public String getYakuName() {
        return "混全带幺九";
    }

    @Override
    public Integer getYakuNum(boolean isMenQing) {
        if(isMenQing) {
            return 2;
        }
        return 1;
    }

}
